1. /* sdfupdtc.cpp by K.Tsuru */
  2. // function ID 3701 DRADIX
  3. #ifndef SN_H
  4. #include "sn.h"
  5. #endif
  6. /*******************************************************
  7. fname = "e.snc", "log10.snc" or "pi.snc"
  8. return NO_SNC_DIR : "SNC_DIR" does not exist.
  9. return SNC_ENOUGH : The constant file has enough length.
  10. return SNC_UPDATE : The constant file has been updated.
  11. ********************************************************/
  12. int UpdateConstantFile(const char* fname,
  13. SDouble (*pfunc)(const SDouble* c, SDouble (*pf)()),
  14. SDouble (*pfCalcFunc)(), uint ef){
  15. char sncFile[SNC_MAX_PATH];
  16. int exist = ExistSncDirectory(sncFile);// If exists, set "SNC_DIR" in "sncFile".
  17. if(!exist){ //There is not "SNC_DIR".
  18. exist = ExistFile(fname); // It searches current directory.
  19. if(!exist) return NO_SNC_FILE; // It does not create *.snc file.
  20. strcpy(sncFile, fname);
  21. } else strcat(sncFile, fname);
  22. //cout << "UpdateConstantFile() is called" << endl;
  23. int enough = 0, existSncFile = ExistFile(sncFile);
  24. if(existSncFile) enough = SetConstByFile(sncFile, (*pfunc),(*pfCalcFunc), ef);
  25. if(enough) return SNC_ENOUGH;
  26. /******** updating constant file **********/
  27. SDouble v;
  28. int format = v.CRLF| v.CONTINUE | v.INT_PUT;
  29. char buff[SNC_MAX_PATH+100];
  30. if(v.ShowMessage()){
  31. sprintf(buff, "%s \"%s\" file.\n", existSncFile ? "Updating" : "Creating", sncFile);
  32. v.ShowMessage(buff);
  33. }
  34. v = (*pfCalcFunc)(); // It evaluates constant.
  35. v.OutPutFile(sncFile, 1); // open file with overwrite
  36. sprintf(buff, "Total digits = %ld.\n", v.DFigures());
  37. v.FPuts(buff);
  38. v.Puts(10, 0, 5, format); // output
  39. v.OutPutFile(NULL); // close file
  40. (*pfunc)(&v, pfCalcFunc); // It sets constant.
  41. return SNC_UPDATE;
  42. }

sdfupdtc.cpp : last modifiled at 2017/07/17 14:52:20(1,737 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).